<HTML><HEAD><TITLE>fix(+Number, -Result)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Arithmetic</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>fix(+Number, -Result)</H1>
Unifies the integer part of Number with Result (Truncation towards zero).


<DL>
<DT><EM>Number</EM></DT>
<DD>A number.
</DD>
<DT><EM>Result</EM></DT>
<DD>A variable or integer.
</DD>
</DL>
<H2>Description</H2>
   This predicate is used by the ECLiPSe compiler to expand evaluable
   arithmetic expressions.  So the call to fix(Number, Result) is
   equivalent to
<PRE>
    Result is fix(Number)
</PRE>
    which should be preferred for portability.
<P>
    This function is deprecated. For clearer code, please use
<PRE>
    Result is integer(truncate(Number)).
</PRE>
<P>
   In coroutining mode, if Number is uninstantiated, the call to fix/2 is
   delayed until this variable is instantiated.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>fix(+, -) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Number is not instantiated (non-coroutining mode only).
<DT><EM>(5) type error </EM>
<DD>Number is of type breal.
<DT><EM>(24) number expected </EM>
<DD>Number is not of a numeric type.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      fix(1.5, 1).
      fix(-6.4, -6).
Fail:
      fix(1, 0).
      fix(0.0, 0.0).
      fix(1, r).
Error:
      fix(A, 6.0).                 (Error 4).
      fix(4 + 2.3, 6).             (Error 24).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/arithmetic/is-2.html">is / 2</A>, <A HREF="../../kernel/arithmetic/integer-2.html">integer / 2</A>, <A HREF="../../kernel/arithmetic/truncate-2.html">truncate / 2</A>, <A HREF="../../kernel/arithmetic/floor-2.html">floor / 2</A>, <A HREF="../../kernel/arithmetic/ceiling-2.html">ceiling / 2</A>, <A HREF="../../kernel/arithmetic/round-2.html">round / 2</A>
</BODY></HTML>
